local BaseData = require("data.base.BaseData")
local EquipmentUnitData = class("EquipmentUnitData", BaseData)

local schema = {}
schema["id"] = {"number", 0}
schema["base_id"] = {"number", 0}
schema["level"] = {"number", 0}
schema["exp"] = {"number", 0}
schema["heroId"] = {"number", 0} -- 装备于
schema["config"] = {"table", {}}
EquipmentUnitData.schema = schema

function EquipmentUnitData:ctor()
    EquipmentUnitData.super.ctor(self)
end

function EquipmentUnitData:getType()
    local TypeHelper = require("utils.TypeHelper")
    return TypeHelper.TYPE_EQUIPMENT
end

function EquipmentUnitData:getPureData()
    local param = {}
    param.id = self:getId()
    param.base_id = self:getBase_id()
    param.level = self:getLevel()
    param.exp = self:getExp()
    param.heroId = self:getHeroId()
    return param
end

function EquipmentUnitData:updateData(data)
    self:setProperties(data)
    local baseId = self:getBase_id()
    local config = require("config.equipment").get(baseId)
    assert(config, "can not found cfg in equipment by id=" .. baseId)
    self:setConfig(config)
end

return EquipmentUnitData
